<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/plantilla/template.xhtml">
	<ui:define name="title">
		<h:outputText value="SAC - Habitaciones" />
	</ui:define>
	<ui:define name="principal">
		<h:form id="form">
			<p:panel header="Habitaciones">
				
					<p:wizard flowListener="#{hotelBean.onFlowProcess}">
					
						<p:tab id="info" title="Tipo de Habitacion">
							<p:spacer width="100" height="15" />
							
							<p:panel header="Agregar Tipo de Habitacion">
								
								
								<table align="center">
									<tr><td colspan="3"><p:spacer width="100" height="15" /></td></tr>
									<tr align="left"><td><h:outputText value="Denominación: *" /></td>
									<td><p:spacer width="20"/></td>
									<td><p:inputText required="true" label="Denominación"
											value="#{hotelBean.nom_habitacion}" /></td>
											</tr>
					
									<tr>
									<td colspan="3"><p:spacer width="100" height="15" /></td>
									</tr>
									<tr align="left">
									<td><h:outputText value="Descripción: *" /></td>
									<td><p:spacer width="20"/></td>
									<td><table>
										<tr>
											<td>
												<p:inputTextarea counter="counter" maxlength="1024"
														rows="6" cols="53"
														counterTemplate="{0} caracteres disponibles."
														autoResize="false" value="#{hotelBean.desc_habitacion}" />
											</td>
										</tr>
										<tr>
											<td><h:outputText id="counter" /></td>
										</tr>
									</table></td>
									</tr>
					
									<tr>
									<td colspan="3"><p:spacer width="100" height="15" /></td>
									</tr>
									<tr align="left">
									<td><h:outputText value="Subir imagenes" /></td>
									<td><p:spacer width="20"/></td>
									<td><h:panelGroup>
										<p:fileUpload id="habimgs" mode="advanced" 
										fileUploadListener="#{hotelBean.subirImgHab}" fileLimit="5"
										sizeLimit="512000" allowTypes="/(\.|\/)(gif|jpe?g|png)$/"
										cancelLabel="Cancelar" uploadLabel="Subir Imágen"
										label="Buscar archivo"/></h:panelGroup></td>
									</tr>
				
									<tr>
									<td colspan="3"><p:spacer width="100" height="15" /></td>
									</tr>
									<tr align="left">
									<td><h:outputText value="Tarifa *" /></td>
									<td><p:spacer width="20"/></td>
									<td><p:inputText required="true" label="Tarifa"
											value="#{hotelBean.tarifa}">
											<f:converter converterId="javax.faces.Float"/>
									</p:inputText></td>
									</tr>
								</table>
								
								
							</p:panel>
							
						</p:tab>
							
							<!--  ######### AGREGAR HABITACION #########  -->
						<p:tab id="hab" title="Agregar Habitacion">
						<p:spacer width="100" height="15" />
						
						<p:panel header="Ingresar Datos de la Habitacion">
						<p:growl id="msgs" />
							
							<table align="center">
									<tr>
									<td colspan="3"><p:spacer width="100" height="15" /></td>
									</tr>
									<tr align="left">
									<td><h:outputLabel value="Número de Habitacion : *" for="txt_title" /></td>
									<td><p:spacer width="20"/></td>
									<td><p:inputText id="txt_title" value="#{hotelBean.habitacion.num_habitacion}" required="true" >
										<f:converter converterId="javax.faces.Integer"/>
										</p:inputText>
									</td>
									</tr>


									<tr>
									<td colspan="3"><p:spacer width="100" height="15" /></td>
									</tr>
									<tr align="left">
									<td><h:outputLabel value="Piso : *" for="txt_author"/></td>
									<td><p:spacer width="20"/></td>
									<td><p:inputText id="txt_author" required="true" value="#{hotelBean.habitacion.piso}">
										<f:converter converterId="javax.faces.Integer"/>
										</p:inputText>
									</td>
									</tr>


									<tr>
									<td colspan="3"><p:spacer width="100" height="15" /></td>
									</tr>
									<tr align="left">
									<td><h:outputLabel value="Estado actual: "/></td>
									<td><p:spacer width="20"/></td>
									<td><p:selectOneRadio id="options" value="#{hotelBean.habitacion.estado}" required="true">
									<f:selectItem itemLabel="Ocupado" itemValue="1" />
									<f:selectItem itemLabel="NO Ocupado" itemValue="0" />
										</p:selectOneRadio></td>
									</tr>


									<tr>
									<td colspan="3"><p:spacer width="100" height="15" /></td>
									</tr>
									<tr align="left">
									<td><p:commandButton value="Reset" type="reset" /></td>
									<td><p:spacer width="20"/></td>
									<td><p:commandButton id="btn_add" value="Agregar" update="books msgs @parent" action="#{hotelBean.reinit}">
									<p:collector value="#{hotelBean.habitacion}" addTo="#{hotelBean.habitaciones}" />
									</p:commandButton></td>
									</tr>
							</table>
							
						
						</p:panel>
							<table>
								<tr><td><p:spacer width="100" height="15" /></td></tr>
							</table>
						<p:outputPanel id="books">
							<p:dataTable id="booksTable" value="#{hotelBean.habitaciones}" var="habitacion">
								<p:column>
									<f:facet name="header">
										<h:outputText value="N° Habitacion" />
									</f:facet>
									<h:outputText value="#{habitacion.num_habitacion}" />
								</p:column>

								<p:column>
									<f:facet name="header">
										<h:outputText value="Piso" />
									</f:facet>
									<h:outputText value="#{habitacion.piso}" />
								</p:column>
								
								<p:column>
									<f:facet name="header">
										<h:outputText value="Estado" />
									</f:facet>
									
									<h:outputText value="#{habitacion.estado}" />
								</p:column>

								<p:column>
									<f:facet name="header">
										<h:outputText value="Eliminar Habitacion" />
									</f:facet>
									<p:commandLink value="Borrar" update=":form:books" process=":form:books">
										<p:collector value="#{habitacion}" removeFrom="#{hotelBean.habitaciones}" />
									</p:commandLink>
								</p:column>

							</p:dataTable>
						</p:outputPanel>

						</p:tab>
						
						<!--  ######### CONFIRMACION #########  -->
						
						<p:tab id="confir" title="Confirmación">
							<p:spacer width="100" height="15" />
							
							<p:fieldset legend="Datos del tipo de habitacion">
						
								
							<table align="center">
									<tr>
									<td colspan="3"><p:spacer width="100" height="15" /></td>
									</tr>
									<tr align="left">
									<td><h:outputText value="Denominación: " /></td>
									<td><p:spacer width="20"/></td>
									<td><h:outputText value="#{hotelBean.nom_habitacion}" /></td>
									</tr>
									<tr>
									<td colspan="3"><p:spacer width="100" height="15" /></td>
									</tr>
									<tr align="left">
									<td><h:outputText value="Descripción: " /></td>
									<td><p:spacer width="20"/></td>
									<td><h:inputTextarea disabled="true" value="#{hotelBean.desc_habitacion}"/></td>
									</tr>
									<tr>
									<td colspan="3"><p:spacer width="100" height="15" /></td>
									</tr>
									<tr align="left">
									<td><h:outputText value="Tarifa: " /></td>
									<td><p:spacer width="20"/></td>
									<td><h:outputText value="#{hotelBean.tarifa}" /></td>
									</tr>
							</table>
							
							</p:fieldset>
							<table>
								<tr><td><p:spacer width="100" height="15" /></td></tr>
							</table>
							<p:fieldset legend="Habiticiones">
							<p:dataTable id="habTable" value="#{hotelBean.habitaciones}" var="habitacion">
								<p:column>
									<f:facet name="header">
										<h:outputText value="N° Habitacion" />
									</f:facet>
									<h:outputText value="#{habitacion.num_habitacion}" />
								</p:column>

								<p:column>
									<f:facet name="header">
										<h:outputText value="Piso" />
									</f:facet>
									<h:outputText value="#{habitacion.piso}" />
								</p:column>

								<p:column>
									<f:facet name="header">
										<h:outputText value="Estado" />
									</f:facet>

									<h:outputText value="#{habitacion.estado}" />
								</p:column>

							</p:dataTable>
						</p:fieldset>
							
							<table align="center">
								<tr><td><p:spacer width="100" height="20" /></td></tr>
								<tr><td><p:commandButton value="Confirmar" action="#{hotelBean.agregarHabitacion}"/></td></tr>
								<tr><td><p:spacer width="100" height="10" /></td></tr>
							</table>
						
						</p:tab>
					</p:wizard>
	
				
			</p:panel>

		</h:form>
	</ui:define>

</ui:composition>
</html>